@isTest
private class PerformanceRightsConfirmationHandlerTest {
    static testMethod void testMethod1() {
        
        Account acc = TestUtils.createAccount();
        acc.Name = '客户A';
        acc.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('DealerAbroad','Account');
        insert acc;

        Id ldcProfile = [Select Id From Profile Where Name like '%工程师%' limit  1  ].Id;

         User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         CompanyName= 'Y-MKSY',
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='客户服务中心(工程部)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         Province__c = '四川省',
                         Username = 'Matldc1@test.com.maike',
                         FederationIdentifier ='123451', 
                         ResponseCode__c = 'TTTT' );
         insert u1;


         PerformanceRightsConfirmation__c prc = new PerformanceRightsConfirmation__c();
         prc.Year__c ='2020年';
         prc.Quarter__c = '一季度';

         prc.Account__c = acc.Id;
         prc.Province__c = '四川';

         prc.Company__c = 'MKSY';
         prc.POCTOwner__c = u1.Id;

         insert prc;

         PerformanceRightsConfirmationController p = new PerformanceRightsConfirmationController();
         p.init();
         p.setNil();
         Map<String,String>searchMap = new Map<String,String>();
         searchMap.put('province','四川');
         p.searchJson = EncodingUtil.urlEncode(JSON.serialize(searchMap), 'UTF-8');
         p.getDetails();
         PerformanceRightsConfirmationController.matchUser(new List<String>{'3451'});
         PerformanceRightsConfirmationController.DetailBean de = new PerformanceRightsConfirmationController.DetailBean(prc);
         List<PerformanceRightsConfirmationController.DetailBean > sL = new List<PerformanceRightsConfirmationController.DetailBean >();
         sl.add(de);

         p.saveJson = EncodingUtil.urlEncode(JSON.serialize(de), 'UTF-8');
         p.save();

         String sql = 'select Id,ProvinceManager__c,DistributionOwner__c,DistributionOwnerManager__c,DirectBusinessOwner__c,DirectBusinessOwnerManager__c,'+
		    'TripartiteOwnerManager__c,TripartiteOwner__c,BiochemicalIOwner__c,BiochemicalIOwnerManager__c,ImmunityOwner__c,'+
		    'ImmunityOwnerManager__c,ClinicalLaboratoryOwner__c,ClinicalLaboratoryOwnerManager__c,PathologyOwner__c,PathologyOwnerManager__c,'+
		    'POCTOwner__c,POCTOwnerManager__c,Account__c,TerminalAccount__c,SysmexOwner__c,SysmexOwnerManager__c,MicrobeOwner__c,MicrobeOwnerManager__c,BDOwner__c,BDOwnerManager__c,MolecularOwner__c,MolecularOwnerManager__c '+
		    'from PerformanceRightsConfirmation__c ';
         PerformanceRightsConfirmationBatch pb = new PerformanceRightsConfirmationBatch(sql);
         Database.executeBatch(pb);

    }
}